$(function() 
{
	if(!isEmptyStr($("#isSuccess").val()))
	{
		alert($("#isSuccess").val());
	}
});

/**
 * 下拉框改变.
 * @return
 */
function changeItem()
{
	doAction(document.forms["publicEvaForm"], "publiceva/publicEva-add.action");
}

/**
 * 录入岗位考核
 * @return
 */
function save()
{
	if (doCheck())
	{
		doAction(document.forms["publicEvaForm"], "publiceva/publicEva-insert.action");
	}
}

/**
 * 画面输入检查
 * @return
 */
function doCheck()
{
	if (isEmptyStr($('#workerCode').val()))
	{
		alert(getMessage(MESSAGE_002, '工作人员编号'));
		$("#workerCode").focus();
		return false;
	}
	
	if (isEmptyStr($('#itemId').val()))
	{
		alert(getMessage(MESSAGE_002, '考核项目'));
		$("#itemId").focus();
		return false;
	}
	
	if (isEmptyStr($('#ruleId').val()))
	{
		alert(getMessage(MESSAGE_002, '考核规则'));
		$("#ruleId").focus();
		return false;
	}
	
	if (isEmptyStr($('#evaTime').val()))
	{
		alert(getMessage(MESSAGE_002, '考核时间'));
		$("#evaTime").focus();
		return false;
	}

	if (isEmptyStr($('#remark').val()))
	{
		alert(getMessage(MESSAGE_001, '备注'));
		$("#remark").focus();
		return false;
	}
	else if ($('#remark').val().Trim().length > 1000)
	{
		alert(getMessage(MESSAGE_003, '备注', '1000'));
		$("#remark").focus();
		return false;
	}
	return true;
}

/**
 * 选择工作人员
 * 
 * @param index
 * @return
 */
function selectWorker()
{
	var value = window.showModalDialog(basePath + 'system/worker-selectList.action', null, 'dialogHeight=500px; dialogWidth=700px;');
	if (value)
	{
		$('#workerCode').val(value.workerCode);
		$('#hdnWorkerName').val(value.workerName);
		setLableValue('workerName', value.workerName);
	}
}

/**
 * 获取工作人员资料
 * @return
 */
function getWorkerInfo()
{
	if(!isEmptyStr($("#workerCode").val()))
	{
		$.ajax({
			  type: "POST",
			  async: false, // 使用同步方式执行AJAX
			  url: "system/worker-getWorkerInfo.action",
			  dataType: "json",
			  data:	"worker.workerCode="+$("#workerCode").val()+"&random="+Math.random(),
			  success:function(data){
			  		if(data != null && data != "")
				  	{
						setLableValue('workerName', data.workerName);
						$('#hdnWorkerName').val(data.workerName);
				  	}
			  		else
			  		{
				  		alert("(工作人员编号："+$("#workerCode").val()+")的不存在！");
						$('#workerCode').val("");
						$('#hdnWorkerName').val("");
						setLableValue('workerName', "");
			  		}
			}
		});
	}
	else
	{
		$('#hdnWorkerName').val("");
		setLableValue('workerName', "");
	}
}